#include <iostream>
#include <mprpcappliaction.h>
#include "mprpcchannel.h"
#include "user.pb.h"
#include "mprpccontroller.h"

int main(int argc, char **argv)
{
    MprpcApplication::Init(argc, argv);
    // google::protobuf::RpcChannel rpcchannel;
    fixbug::UserServiceRpc_Stub user_stub(new MprpcChannel());

    fixbug::LoginRequest request;
    request.set_name("zhangsan");
    request.set_pwd("123456");
    fixbug::LoginResponse response;

    MprpcController controller;

    user_stub.Login(&controller, &request, &response, nullptr);

    if (controller.Failed())
    {
        std::cout << controller.ErrorText() << std::endl;
    }
    else
    {
        if (response.result().errcode() == 0)
        {
            std::cout << "rpc login response success: " << response.success() << std::endl;
        }
        else
        {
            std::cout << "rpc login response error: " << response.result().errmsg() << std::endl;
        }
    }
    return 0;
}